<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Microsites</title>

	<!-- EXT JS LIBRARY & CSS -->
	<script type="text/javascript" src="<%=request.getContextPath()%>/extjs/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/extjs/ext-all-debug.js"></script>
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/extjs/resources/css/ext-all.css" />
	<!-- /EXT JS LIBRARY & CSS -->

	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/UserRemote.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/GroupRemote.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/HostRemote.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/DatabaseRemote.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/DeploymentRemote.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/ShareRemote.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/FileSetRemote.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/ProjectRemote.js'></script>
	<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/ServerRemote.js'></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/common/ext-dwr.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/common/fieldpanel.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/common/Utilities.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/database/DatabaseEditor.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/database/DatabaseView.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/deployment/DeploymentEditor.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/deployment/DeploymentView.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/group/GroupEditor.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/group/GroupView.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/host/HostEditor.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/host/HostView.js"></script>
	
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/fileset/FileSetEditor.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/fileset/FileSetView.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/project/ProjectEditor.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/project/ProjectView.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/server/ServerEditor.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/server/ServerView.js"></script>

    <script type="text/javascript" src="<%=request.getContextPath()%>/js/share/ShareEditor.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/share/ShareView.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/user/UserView.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/js/user/LoginWindow.js"></script>

	<script type="text/javascript" src="<%=request.getContextPath()%>/js/common/ObjectBrowser.js"></script>

	<style type="text/css">
		.hosticon { background-image: url(<%=request.getContextPath()%>/img/icons/computer.png) !important; }
		.usericon { background-image: url(<%=request.getContextPath()%>/img/icons/user.png) !important; }
		.dbicon { background-image: url(<%=request.getContextPath()%>/img/icons/database.png) !important; }
		.servericon { background-image: url(<%=request.getContextPath()%>/img/icons/cog.png) !important; }
		.shareicon { background-image: url(<%=request.getContextPath()%>/img/icons/drive.png) !important; }
		.fileseticon { background-image: url(<%=request.getContextPath()%>/img/icons/folder.png) !important; }
		.deploymenticon { background-image: url(<%=request.getContextPath()%>/img/icons/plugin.png) !important; }
		.mailicon { background-image: url(<%=request.getContextPath()%>/img/icons/email.png) !important; }
		.svnicon { background-image: url(<%=request.getContextPath()%>/img/icons/svn.png) !important; }
		.ftpicon { background-image: url(<%=request.getContextPath()%>/img/icons/ftp.png) !important; }
		.wwwicon { background-image: url(<%=request.getContextPath()%>/img/icons/www.png) !important; }
		.dbmsicon { background-image: url(<%=request.getContextPath()%>/img/icons/dbms.png) !important; }
		.smbicon { background-image: url(<%=request.getContextPath()%>/img/icons/share.png) !important; }
		
		button.refresh { background-image: url(<%=request.getContextPath()%>/img/icons/arrow_refresh.png); }

		button.hostcreate { background-image: url(<%=request.getContextPath()%>/img/icons/computer_add.png); }
		button.hostdelete { background-image: url(<%=request.getContextPath()%>/img/icons/computer_delete.png); }
		button.hostedit   { background-image: url(<%=request.getContextPath()%>/img/icons/computer_edit.png); }
		
		button.copyicon { background-image: url(<%=request.getContextPath()%>/img/icons/page_copy.png); }
		button.pasteicon { background-image: url(<%=request.getContextPath()%>/img/icons/page_paste.png); }
		
		button.addicon { background-image: url(<%=request.getContextPath()%>/img/icons/add.png); }
		button.delicon { background-image: url(<%=request.getContextPath()%>/img/icons/delete.png); }
		
	</style>
	

	<script type="text/javascript">

	Ext.namespace("org.microsite.globals");

	function initGroups() {
        GroupRemote.sublist(null, function(list) {
            org.microsite.globals.RootGroups = {};
            for (var i = 0; i < list.length; i++) {
                org.microsite.globals.RootGroups[list[i].name] = list[i];
            }
        });

        Ext.TaskMgr.start({
            run: function() {
                UserRemote.ping();
            },
            interval: 300000
        });
	}

    Ext.onReady(function(){
		Ext.QuickTips.init();

		UserRemote.getCurrentUser(function(user) {
			if (user) initGroups();
		});
    });

	function onLogin() {
		var win = new org.microsite.user.LoginWindow();
		win.on("login", initGroups);
		win.show();
	}
	
	function onHosts() {
		var win = new org.microsite.util.ObjectBrowserWindow({
			browserConfig : {
				root : org.microsite.globals.RootGroups['[microsites]'],
				nodeFilter : function(ctype) {
					return ctype != Project && ctype != User;
				}
			}
		});
		win.show();
	}
	
	function onProjects() {
		var win = new org.microsite.util.ObjectBrowserWindow({
			browserConfig : {
				root : org.microsite.globals.RootGroups['[projects]'],
				nodeFilter : function(ctype) {
					return ctype != Host && ctype != User && ctype != FileSet;
				}
			}
		});
		win.show();
	}
	
	</script>
</head>
<body>

<input type="button" value="login" onclick="javascript: onLogin();"/>
<input type="button" value="hosts" onclick="javascript: onHosts();"/>
<input type="button" value="projects" onclick="javascript: onProjects();"/>

</body>
</html>